<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>adjacent_difference</title>
<link rel="stylesheet" href="../../../../../../../../doc/html/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../../index.html" title="Chapter&#160;1.&#160;Range 2.0">
<link rel="up" href="../numeric.html" title="Numeric algorithms">
<link rel="prev" href="accumulate.html" title="accumulate">
<link rel="next" href="inner_product.html" title="inner_product">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="accumulate.html"><img src="../../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../numeric.html"><img src="../../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="inner_product.html"><img src="../../../../../../../../doc/html/images/next.png" alt="Next"></a>
</div>
<div class="section" title="adjacent_difference">
<div class="titlepage"><div><div><h5 class="title">
<a name="range.reference.algorithms.numeric.adjacent_difference"></a><a class="link" href="adjacent_difference.html" title="adjacent_difference">
          adjacent_difference</a>
</h5></div></div></div>
<a name="range.reference.algorithms.numeric.adjacent_difference.prototype"></a><h6>
<a name="id655140"></a>
            <a class="link" href="adjacent_difference.html#range.reference.algorithms.numeric.adjacent_difference.prototype">Prototype</a>
          </h6>
<p>

</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
    <span class="keyword">class</span> <span class="identifier">SinglePassRange</span><span class="special">,</span>
    <span class="keyword">class</span> <span class="identifier">OutputIterator</span>
    <span class="special">&gt;</span>
<span class="identifier">OutputIterator</span> <span class="identifier">adjacent_difference</span><span class="special">(</span>
    <span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">&amp;</span> <span class="identifier">source_rng</span><span class="special">,</span>
    <span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">);</span>

<span class="keyword">template</span><span class="special">&lt;</span>
    <span class="keyword">class</span> <span class="identifier">SinglePassRange</span><span class="special">,</span>
    <span class="keyword">class</span> <span class="identifier">OutputIterator</span><span class="special">,</span>
    <span class="keyword">class</span> <span class="identifier">BinaryOperation</span>
    <span class="special">&gt;</span>
<span class="identifier">OutputIterator</span> <span class="identifier">adjacent_difference</span><span class="special">(</span>
    <span class="keyword">const</span> <span class="identifier">SinglePassRange</span><span class="special">&amp;</span> <span class="identifier">source_rng</span><span class="special">,</span>
    <span class="identifier">OutputIterator</span> <span class="identifier">out_it</span><span class="special">,</span>
    <span class="identifier">BinaryOperation</span> <span class="identifier">op</span><span class="special">);</span>
</pre>
<p>
          </p>
<a name="range.reference.algorithms.numeric.adjacent_difference.description"></a><h6>
<a name="id655401"></a>
            <a class="link" href="adjacent_difference.html#range.reference.algorithms.numeric.adjacent_difference.description">Description</a>
          </h6>
<p>
            <code class="computeroutput"><span class="identifier">adjacent_difference</span></code> calculates
            the differences of adjacent_elements in <code class="computeroutput"><span class="identifier">rng</span></code>.
          </p>
<p>
            The first version of <code class="computeroutput"><span class="identifier">adjacent_difference</span></code>
            uses <code class="computeroutput"><span class="keyword">operator</span><span class="special">-()</span></code>
            to calculate the differences. The second version uses <code class="computeroutput"><span class="identifier">BinaryOperation</span></code>
            instead of <code class="computeroutput"><span class="keyword">operator</span><span class="special">-()</span></code>.
          </p>
<a name="range.reference.algorithms.numeric.adjacent_difference.definition"></a><h6>
<a name="id655506"></a>
            <a class="link" href="adjacent_difference.html#range.reference.algorithms.numeric.adjacent_difference.definition">Definition</a>
          </h6>
<p>
            Defined in the header file <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">numeric</span><span class="special">.</span><span class="identifier">hpp</span></code>
          </p>
<a name="range.reference.algorithms.numeric.adjacent_difference.requirements"></a><h6>
<a name="id655569"></a>
            <a class="link" href="adjacent_difference.html#range.reference.algorithms.numeric.adjacent_difference.requirements">Requirements</a>
          </h6>
<a name="range.reference.algorithms.numeric.adjacent_difference.for_the_first_version"></a><h6>
<a name="id655593"></a>
            <a class="link" href="adjacent_difference.html#range.reference.algorithms.numeric.adjacent_difference.for_the_first_version">For
            the first version</a>
          </h6>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange</span></code> is
              a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
              Pass Range</a> Concept.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">OutputIterator</span></code> is a
              model of the <code class="computeroutput"><span class="identifier">OutputIteratorConcept</span></code>.
            </li>
<li class="listitem">
              If <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code> are objects of <code class="computeroutput"><span class="identifier">SinglePassRange</span></code>'s
              value type, then <code class="computeroutput"><span class="identifier">x</span> <span class="special">-</span> <span class="identifier">y</span></code>
              is defined.
            </li>
<li class="listitem">
              The value type of <code class="computeroutput"><span class="identifier">SinglePassRange</span></code>
              is convertible to a type in <code class="computeroutput"><span class="identifier">OutputIterator</span></code>'s
              set of value types.
            </li>
<li class="listitem">
              The return type of <code class="computeroutput"><span class="identifier">x</span> <span class="special">-</span> <span class="identifier">y</span></code>
              is convertible to a type in <code class="computeroutput"><span class="identifier">OutputIterator</span></code>'s
              set of value types.
            </li>
</ol></div>
<a name="range.reference.algorithms.numeric.adjacent_difference.for_the_second_version"></a><h6>
<a name="id655790"></a>
            <a class="link" href="adjacent_difference.html#range.reference.algorithms.numeric.adjacent_difference.for_the_second_version">For
            the second version</a>
          </h6>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange</span></code> is
              a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
              Pass Range</a> Concept.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">OutputIterator</span></code> is a
              model of the <code class="computeroutput"><span class="identifier">OutputIteratorConcept</span></code>.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">BinaryOperation</span></code> is
              a model of the <code class="computeroutput"><span class="identifier">BinaryFunctionConcept</span></code>.
            </li>
<li class="listitem">
              The value type of <code class="computeroutput"><span class="identifier">SinglePassRange</span></code>
              is convertible to <code class="computeroutput"><span class="identifier">BinaryOperation</span></code>'s
              first and second argument types.
            </li>
<li class="listitem">
              The value type of <code class="computeroutput"><span class="identifier">SinglePassRange</span></code>
              is convertible to a type in <code class="computeroutput"><span class="identifier">OutputIterator</span></code>'s
              set of value types.
            </li>
<li class="listitem">
              The result type of <code class="computeroutput"><span class="identifier">BinaryOperation</span></code>
              is convertible to a type in <code class="computeroutput"><span class="identifier">OutputIterator</span></code>'s
              set of value types.
            </li>
</ol></div>
<a name="range.reference.algorithms.numeric.adjacent_difference.precondition_"></a><h6>
<a name="id655972"></a>
            <a class="link" href="adjacent_difference.html#range.reference.algorithms.numeric.adjacent_difference.precondition_">Precondition:</a>
          </h6>
<p>
            <code class="computeroutput"><span class="special">[</span><span class="identifier">result</span><span class="special">,</span> <span class="identifier">result</span>
            <span class="special">+</span> <span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng</span><span class="special">))</span></code> is a valid range.
          </p>
<a name="range.reference.algorithms.numeric.adjacent_difference.complexity"></a><h6>
<a name="id656046"></a>
            <a class="link" href="adjacent_difference.html#range.reference.algorithms.numeric.adjacent_difference.complexity">Complexity</a>
          </h6>
<p>
            Linear. If <code class="computeroutput"><span class="identifier">empty</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span></code>
            then zero applications, otherwise <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span> <span class="special">-</span> <span class="number">1</span></code>
            applications are performed.
          </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2010 Thorsten Ottosen, Neil Groves<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="accumulate.html"><img src="../../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../numeric.html"><img src="../../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="inner_product.html"><img src="../../../../../../../../doc/html/images/next.png" alt="Next"></a>
</div>
</body>
</html>
